package com.geeklan.smart.widget;

import android.graphics.Rect;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;

public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {

    private int verticalSpacing;

    // 构造方法，传入上下间距值
    public GridSpacingItemDecoration(int verticalSpacing) {
        this.verticalSpacing = verticalSpacing;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);

        // 设置每个item的上下间距
        outRect.top = verticalSpacing;
        outRect.bottom = verticalSpacing;
    }
}

